package memcached;

import net.spy.memcached.ConnectionFactory;
import net.spy.memcached.DefaultConnectionFactory;
import net.spy.memcached.KetamaConnectionFactory;
import net.spy.memcached.MemcachedClient;
import net.spy.memcached.internal.OperationFuture;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.concurrent.ExecutionException;

public class MemcachedTest {
    public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {

        InetSocketAddress inetSocketAddress = new InetSocketAddress(11212);
        ConnectionFactory connectionFactory = new KetamaConnectionFactory();
        MemcachedClient client = new MemcachedClient(connectionFactory, Arrays.asList(inetSocketAddress));
        OperationFuture<Boolean> operationFuture1 = client.set("foo", 1000, "foo");
        OperationFuture<Boolean> operationFuture2 = client.set("foo1", 1000, "foo1");
        System.out.println(operationFuture1.get() && operationFuture2.get());
        System.out.println(client.getBulk(Arrays.asList("foo","foo1")));
        System.out.println("1");
        client.shutdown();

    }
}
